﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

<LINK REL='stylesheet' HREF='../source/RuleCompiler.css' type='text/css'>

<script src="esoe.r.js" id='_ESOE_ENGINE_' debug='1'></script>
<script src="../source/RuleCompiler.js"></script>
<script src="../source/RuleHtml.js"></script>
<script src="../source/RuleJavascript.js"></script>
<script src="../source/RuleXslt.js"></script>
<script src="../source/TextParser.js"></script>
<script src="../source/TextEditor.js"></script>

<script>
var RuleCompiler= $esoe.$declare("org.supertree.editor.RuleCompiler");
var TextParser= $esoe.$declare("org.supertree.editor.TextParser");
var RuleXslt= $esoe.$declare("org.supertree.editor.RuleXslt");
var RuleJavascript= $esoe.$declare("org.supertree.editor.RuleJavascript");
var RuleHtml= $esoe.$declare("org.supertree.editor.RuleHtml");

var oParser= new TextParser("oParser");

function changerule()
{
	oParser.InitViewer(
		document.getElementById("divEditor"),
		1,
		1,
		0,
		RuleXslt.rule
		);
	oParser.SetText(
		document.getElementById("txtData").value
		);
}

function changerule2()
{
	oParser.InitViewer(
		document.getElementById("divEditor"),
		1,
		1,
		0,
		RuleJavascript.rule
		);
	oParser.SetText(
		document.getElementById("txtData2").value
		);
}

function changerule3()
{
	oParser.InitViewer(
		document.getElementById("divEditor"),
		1,
		1,
		0,
		RuleHtml.rule
		);
	oParser.SetText(
		document.getElementById("txtData3").value
		);
}

function test_self()
{
	var s= document.getElementById("txt_r").value;
	var r=eval(s);
	RuleCompiler.Compile(r);
	//alert(r);
	r.sEndStack="|0|";
	
	oParser.InitViewer(
		document.getElementById("divEditor"),
		1,
		1,
		0,
		r
		);
	oParser.SetText(
		document.getElementById("txt_t").value
		);
}

</script>

<head>
<body onload="changerule()">

<textarea id="txtData">
<xsl:include href="CopySafeXHTMLV2.xsl"/>
<xsl:include href="CopyXmlForTextarea.xsl"/>

<xsl:template match="R" mode="GroupNodeList">
	<xsl:variable name="PNID" select="@*[name(.)=$FNID]"/>
	
	<xsl:for-each select="key('NodeData_PNID',$PNID)">
		<xsl:variable name="NID" select="@*[name(.)=$FNID]"/>
		<xsl:if test="not(key('PhysData_Key',$NID))">
			<xsl:value-of select="concat(',',$NID)"/>
			<xsl:apply-templates select="." mode="GroupNodeList"/>
		</xsl:if>
	</xsl:for-each>
</xsl:template>
</textarea>

<textarea id="txtData2">
function getInnerText(obj)
{
	if( window.ActiveXObject )
	{
		return obj.innerText;
	}
	else
	{
		return obj.textContent;
	}
}
</textarea>


<textarea id="txtData3">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>
<body>
<a href="http://www.supertree.org">Supertree</a>
</body>
</html>
</textarea>

<hr>
<table>
	<tr>
		<td style="padding-right:2em;">
			<div id="divEditor" style="border:1px solid black;width:500px;height:400px;overflow-x:scroll;overflow-y:scroll;"></div>
		</td>
		<td style="border:1px solid gray;padding:15px;" valign=top>
			<b>Self-define Rule</b><br>
			text<br>
			<textarea id="txt_t" style="width:25em;height:10em;">
body{font-color:red;}
.cls{font-size:blue;}</textarea><br>
			self-defined rule<br>
			<textarea id="txt_r" style="width:25em;height:10em;" wrap=off>
[
  "({)|(body)|($)",
  ["BlueB","",1,"",
    [
      "(\\b(?:font-color|font-size))|(})|($)",
      ["GreenB","",0],
      ["BlueB","",-1],
      ["","",0]
    ]
  ],
  ["BrownB","",0],
  ["","",0]
]
</textarea><br>
			<button onclick="test_self()">test</button>
		</td>
	</tr>
</table>
<hr>
<button onclick="changerule()">Xslt</button>
<button onclick="changerule2()">Javascript</button>
<button onclick="changerule3()">Html</button>
</body>
</html>
